VideoToolbox: "Improve Numerical Recipes v 2.note"
June 15, 1993; revised January 23, 1996
Numerical Recipes C Diskette for Macintosh, 2nd ed. $31.96 (software)
Numerical Recipes in C: The Art of Scientific Computing, 2nd ed. $39.96 (book)
OR
Numerical Recipes C Set for Macintosh (main book, example book, and disk) $90
Useful book and mathematical library in source form, so you can read the code, understand what’s going on, and modify it if necessary. From:
Cambridge University Press
40 West 20th Street
New York, NY 10010-4211
(800)-227-0247
http://nr.harvard.edu/nr/store/storefront.html
The VideoToolbox routines that use the recipes assume that you have made the following five changes to the Numerical Recipes in C routines:
1A. If you care about speed when compiled to run on 68k macs with floating point units: In every file, change every "float" to "FLOAT", and insert the line "#include <nr.h>" at the beginning of the file. Insert these statements
#if GENERATING68K && GENERATING68881
typedef double FLOAT;
#else
typedef float FLOAT;
#endif
into the file nr.h. This is because 68k+fpu Macs compute doubles much faster than floats, whereas the reverse is true on most computers, including the PowerPC Macs.
1B. Alternatively, if you'd rather run slowly than modify your Numerical Recipes files, then you will need to insert "typedef float FLOAT;" in CalibrateLuminance.c and PsychometricFit.c in order to compile those files. The rest of the VideoToolbox doesn't care.
2. Add #include "nrutil.h" as second line of nrutil.c.
3. Add "#pragma once" at the top of nr.h and nrutil.h. This will allow you to include these headers freely in your THINK C files, without worrying about whether you've inadvertently included them twice.
4. In order to produce reasonable polynomial fits it is necessary to reduce the TOL parameter in the file SVDFIT.C to a small value, e.g. 1.0e-14. Otherwise the fits will not be very good, and will have the nonintuitive property that the fit will get WORSE as the order of the polynomial is increased.
5. I like to include the precompiled header VideoToolbox.h in a prefix line for my whole project. This causes it to be included in the Numerical Recipes files, which don't need it. The only conflict I've found is that PI is defined both in VideoToolbox.h and in BNLDEV.C, which I fixed by first undefining it in BNLDEV.c:
#undef PI /* added by dgp, for compatibility with VideoToolbox.h */